﻿using System.Diagnostics;
using EFTracingProvider;
using TSharp.Core.Repository;
[assembly: TSharp.Core.Osgi.RegAppEvent(typeof(SetSqlTracingFormat))]
namespace TSharp.Core.Repository
{
    public class SetSqlTracingFormat : IAppHandler
    {
        public void OnStart(AppEventArgs args)
        {
            EFTracingProviderConfiguration.LogAction = info =>
            {
                Debug.WriteLine("");
                switch (info.Status)
                {
                    case CommandExecutionStatus.Executing:

                        Debug.WriteLine("--#{0} 开始执行 {1}:", info.CommandId, info.Method);
                        Debug.WriteLine(info.ToTraceString());
                        break;
                    case CommandExecutionStatus.Failed:
                        Debug.WriteLine("--#{0} 命令失败 {1}", info.CommandId, info.Result);
                        break;
                    case CommandExecutionStatus.Finished:
                        Debug.WriteLine("--#{0} 命令执行完毕 耗时：{1}", info.CommandId, info.Duration);
                        break;
                    default:
                        break;
                }
                Debug.WriteLine("");
            };
        }


        public void OnStop(AppEventArgs args)
        {
             
        }
    }
}